package com.yang.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author yanwei.yang
 * @date 2021/11/11 17:50
 * @description:
 */
@Controller
public class IndexController {


    @ResponseBody
    @RequestMapping(value = "test")
    public String test() {
        return "test";
    }


    @RequestMapping(value = "say")
    public ModelAndView say() {
        ModelAndView mv = new ModelAndView();
        mv.addObject("msg", "hi,springboot,1");
        mv.setViewName("say");
        return mv;
    }


    @RequestMapping("index")
    public String index(Model model) {
        model.addAttribute("msg", "hi,springboot,2");
        return "say";
    }

}
